import { Component, OnInit, EventEmitter, Input, Output, ElementRef } from '@angular/core';

import { Service } from '../../../server/server';
import { HttpClientModule, HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Http } from '@angular/http';
import { HintsService } from '../../../public/serve/hints/hints.service';
declare var $: any;

@Component({
  selector: 'app-management-update-passwordreset',
  templateUrl: './management-update-passwordreset.component.html'
})
export class ManagementUpdatePasswordresetComponent implements OnInit {

  constructor(
    private server: Service, 
    private http: HttpClient,
    private hintsService:HintsService
    ) { }

  ngOnInit() {
  }

  @Input() getTabVal: any;

  setpasswordReset(): void {
    let url = this.server.baseUrl+'admin/pusers/restpw';
    let body = {
      userId: this.getTabVal.userId,
      userName: this.getTabVal.userName
    }
    //console.log(body)
    this.http.post<Response>(url, body).subscribe((res: any) => {
      //console.log(res)
      this.hintsService.messages(res.message,res.result_code);
      if (res.result_code === '0000') {
        $('#passwordReset').modal('hide');
        //prompt
        //update
      }
    })
  }

}
